<%@page import="com.shoeshopping.entity.Goods"%>
<%@page import="com.shoeshopping.entity.OrderItem"%>
<%@page import="com.shoeshopping.entity.Order"%>
<%@page import="com.shoeshopping.entity.User"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";

	User user = ((User) session.getAttribute("user"));
	String username = null;
	if (user != null) {
		username = user.getUsername();
	}
	List orders = (List) session.getAttribute("ordersList");
	System.out.println("+++++++---------------" + orders.size());
	 double total=0;
%>

<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">
<title>订单</title>
<meta name="viewport" content="width=device-width, initial-scale=1">

<link href="css/style.css" rel='stylesheet' type='text/css' />
<link href="css/bootstrap.min.css" rel='stylesheet' type='text/css' />

<script src="js/jquery-1.9.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
</script>
<!----webfonts---->
<link href='css/css.css?family=Open+Sans:400,300,600,700,800'
	rel='stylesheet' type='text/css'>
<!----//webfonts---->
<script src="js/jquery.min.js"></script>
<!----start-alert-scroller---->
<script type="text/javascript" src="js/jquery.easy-ticker.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		$('#demo').hide();
		$('.vticker').easyTicker();
	});
</script>

<!----start-alert-scroller---->
<!-- start menu -->
<link href="css/megamenu.css" rel="stylesheet" type="text/css"
	media="all" />
<script type="text/javascript" src="js/megamenu.js"></script>
<script>
	$(document).ready(function() {
		$(".megamenu").megamenu();
	});
</script>
<script src="js/menu_jquery.js"></script>
<!-- //End menu -->
<!---move-top-top---->
<script type="text/javascript" src="js/move-top.js"></script>
<script type="text/javascript" src="js/easing.js"></script>
<script type="text/javascript">
	jQuery(document).ready(function($) {
		$(".scroll").click(function(event) {
			event.preventDefault();
			$('html,body').animate({
				scrollTop : $(this.hash).offset().top
			}, 1200);
		});
	});
</script>
<!---//move-top-top---->
</head>
<body>
	<!---start-wrap---->
	<!---start-header---->
	<div class="header">
		<%
			//jsp include进 top-header
		%>
		<jsp:include page="/component/top-header.jsp" flush="true">
			<jsp:param value='<%=username %>' name="username" />
		</jsp:include>

		<%
			//jsp include进 middle-header
		%>
		<jsp:include page="/component/middle-header.jsp" flush="true" />

		<%
			//jsp include进 middle-header
		%>
		<jsp:include page="/component/bottom-header.jsp" flush="true" />

		<div class="clear"></div>
	</div>
	</div>
	</div>
	<div class="content contact-main">
		<div class="contact-info">
			<div class="container">
				<%
					if(orders==null || orders.size()<=0){
					%>
					<div class="container">
					<div class="row" style="margin-top:100px;text-align: center;">
					<label style="font-size:40px;">
					您暂时还没有订单哦亲！
					</label>
				</div>
			</div>
					<%
					}
				 %>
				<%
					for (int i = 0; i < orders.size(); i++) {
						total = 0;
						Order order = (Order) orders.get(i);
						List orderItems = order.getOrderItem();
						System.out.println("-----orderItems.size----" + orderItems.size());
				%>
				<div class="row order" style="margin-top:20px;">
					<div class="col-md-3"></div>
					<div class="col-md-6"
						style="border-bottom: 1px solid #DDDDDD;  margin-bottom: 15px;">
						<h4 style="float:left;">订单编号：</h4>
						<p style="float:left;margin-top:10px"><%=order.getId()%></p>
					</div>
				</div>
				<div class="row">
					<div class="col-md-3"></div>
					<div class="col-md-6">
						<table class="table table-hover table-striped">
							<thead>
								<td>商品编号</td>
								<td>商品名</td>
								<td>数量(双)</td>
								<td>价格(元)</td>
							</thead>
							<tbody>
								<%
									for (int j = 0; j < orderItems.size(); j++) {
											OrderItem orderItem = (OrderItem) orderItems.get(j);
											Goods goods = orderItem.getGoods();
											total += goods.getPrice() * orderItem.getNum();
								%>
								<tr>
									<td><%=orderItem.getGoods().getId()%></td>
									<td><%=orderItem.getGoods().getName()%></td>
									<td><%=orderItem.getNum()%></td>
									<td><%=orderItem.getNum() * orderItem.getGoods().getPrice()%></td>
								</tr>
								<%
									}
								%>

							</tbody>
						</table>
					</div>
				</div>

				<div class="row">
					<div class="col-md-3"></div>
					<div class="col-md-6"
						style="border-bottom: 1px solid #DDDDDD;  margin-bottom: 30px;">
						<h3>总计:<%=total %></h3>
					</div>
				</div>

				<%
					}
				%>


			</div>
		</div>
	</div>
	</div>

</body>
</html>

